﻿using HamcoWcs.Contract.ContractMainTask.IMainTaskParsers;
using HamcoWcs.Models.Common.Enums;
using HamcoWcs.Service.Common;
using System.Collections.Generic;
using System.Linq;

namespace HamcoWcs.Service.MainTasks.SubTaskParsers
{
    [AutoInject(typeof(ISubTaskParseFactory), InjectType.Scope)]
    public class MainTaskStatusFactory : ISubTaskParseFactory
    {
        public MainTaskStatusFactory(IEnumerable<ISubTaskParser> subTaskParsers)
        {
            _subTaskParsers = subTaskParsers;
        }

        public IEnumerable<ISubTaskParser> _subTaskParsers { get; }

        public ISubTaskParser CreateParser(EnumSubTaskType subTaskType)
            => _subTaskParsers.FirstOrDefault(x => x.SubTaskType == subTaskType);
    }
}
